package com.easyweb.session;

import com.easyweb.entity.*;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.EntityManager;

@Name("yabanciDilList")
public class YabanciDilList extends EntityQuery<YabanciDil> {

	@In private EntityManager entityManager;
	private static final String EJBQL = "select yabanciDil from YabanciDil yabanciDil";

	private static final String[] RESTRICTIONS = { "lower(yabanciDil.yabanciDilAdi) like lower(concat(#{yabanciDilList.yabanciDil.yabanciDilAdi},'%'))", };

	private YabanciDil yabanciDil = new YabanciDil();
	private List<YabanciDil> yabanciDilList=null;

	public YabanciDilList() {
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	private void yabanciDilListesiOlustur(){
		yabanciDilList=new ArrayList<YabanciDil>();
		yabanciDilList=entityManager.createNamedQuery("yabanciDilTumKayitlar").getResultList();
		
	}
	public YabanciDil getYabanciDil() {
		return yabanciDil;
	}

	public List<YabanciDil> getYabanciDilList() {
		if (yabanciDilList==null) yabanciDilListesiOlustur();
		return yabanciDilList;
	}

	public void setYabanciDilList(List<YabanciDil> yabanciDilList) {
		this.yabanciDilList = yabanciDilList;
	}
}
